function $(id)
{
	return document.getElementById(id);
}
function $F(id)
{
	return document.getElementById(id).contentWindow;
}
function $$(ifrid,id)
{
	return document.getElementById(ifrid).contentWindow.document.getElementById(id);
}
function getWinFID(winID)
{
	return Qwindows.getWindow(winID).iframeid;
}
function getWinIfr(winID)
{
	return $(Qwindows.getWindow(winID).iframeid).contentWindow;
}
function $$Win(winID,id)
{
	return document.getElementById(getWinFID(winID)).contentWindow.document.getElementById(id);
}
function insertAfter(newElement, targetElement)
{
    var parent = targetElement.parentNode;
    if(parent.lastChild == targetElement)
    {
        parent.appendChild(newElement);
    }
    else
    {
        parent.insertBefore(newElement, targetElement.nextSibling);
    }
}
function stop()
{
	return false;
}
document.oncontextmenu=stop;
var EventUtil = function(){};
EventUtil.addEventHandler = function(obj,EventType,Handler)
{
	if(obj.addEventListener)
	{
		obj.addEventListener(EventType,Handler,false);
	}
	else if(obj.attachEvent)
	{
		obj.attachEvent('on'+EventType,Handler);
	}
	else
	{
		obj['on'+EventType] = Handler;
	}
}
EventUtil.removeEventHandler = function(obj,EventType,Handler)
{
	if(obj.removeEventListener)
	{
		obj.removeEventListener(EventType,Handler,false);
	}
	else if(obj.detachEvent)
	{
		obj.detachEvent('on'+EventType,Handler);
	}
	else
	{
		obj['on'+EventType] = Handler;
	}
}
EventUtil.getEvent = function (evt)
{
	return (evt ? evt : (window.event ? window.event : EventUtil.getEvent.caller.arguments[0]));
}
EventUtil.getEventX = function (evt)
{
	if (!evt)
	{
		return 0;
	}
	var x = parseInt(evt.clientX ? evt.clientX : evt.pageX);
	if (isNaN(x))
	{
		return 0;
	}
	else
	{
		return x;
	}
}
EventUtil.getEventY = function (evt)
{
	if (!evt)
	{
		return 0;
	}
	var y = parseInt(evt.clientY ? evt.clientY : evt.pageY);
	if (isNaN(y))
	{
		return 0;
	}
	else
	{
		return y;
	}
}
function stopEvent(e)
{
    if (!e) e = window.event;
    if (e.stopPropagation)
    {
        e.stopPropagation();
    } else
    {
        e.cancelBubble = true;
    }
}
function cancelEvent(e)
{
    if (!e) e = window.event;
    if (e.preventDefault)
    {
        e.preventDefault();
    }
    else
    {
        e.returnValue = false;
    }
}
function Qwindows () {};
Qwindows.path       = "../images/coos/windows/";
Qwindows.winIndex	= 2;
Qwindows.winL		= 100;
Qwindows.winT		= 100;
Qwindows.winW		= 630;
Qwindows.winH		= 450;
Qwindows.winCount	= 0;
Qwindows.winPosition= 0;
Qwindows.main		= null;
Qwindows.startbar	= null;
Qwindows.workbar	= null;
Qwindows.sysbar		= null;
Qwindows.worktabW   = 80;
Qwindows.winWidth   = 0;
Qwindows.winHeight  = 0;
Qwindows.x          = 0;
Qwindows.y          = 0;
Qwindows.moveid     = "";
Qwindows.Deskid     = "";
Qwindows.tabid      = "";
Qwindows.BackColor  = "#1e4683";
Qwindows.BackImage  = "mainbg.jpg";
Qwindows.preTopDiv  = null;
Qwindows.windows    = coos.hashmap();
Qwindows.desks      = coos.hashmap();
Qwindows.WinLogo    = "defaultWinLogo.gif";
Qwindows.setPath = function(path)
{
	Qwindows.path = path;
}
function QMain ()
{
	this.div = document.createElement ("div");
	this.div.id = "mainDiv";
	this.mainStyle = "margin:0px;padding:0px;position:absolute;left:0px;top:0px;width:" + Qwindows.mainW + "px;height:" + Qwindows.mainH + "px;background-color:" + Qwindows.BackColor + ";background-image:url(" + Qwindows.path + Qwindows.BackImage + ");background-position: left top;background-repeat:repeat-x;";
	this.div.style.cssText = this.mainStyle;
}
Qwindows.setBackgroundColor = function (color)
{
	$("mainDiv").style.backgroundImage = "";
	$("mainDiv").style.backgroundColor = color;
}
Qwindows.setBackgroundImage = function(url)
{
	$("mainDiv").style.backgroundImage = "";
	var div = document.createElement("div");
	div.id  = "mainDiv_bgdiv";
	div.style.left = "0px";
	div.style.top  = "0px";
	div.style.width = Qwindows.mainW + "px";
	div.style.height = Qwindows.mainH + "px";
	div.style.zIndex = 1;
	div.style.textAlign = "center";
	div.style.MozUserSelect = "none";
	$("mainDiv").appendChild(div);
	if(coos.browser.msie)
	{
		div.onselectstart = function(){return false;};
	}
	var img = document.createElement("img");
	img.id  = "mainDiv_bgimg";
	img.src = url;
	div.appendChild(img);
	if(parseInt(img.width)*parseInt(div.style.height) >= parseInt(div.style.width)*parseInt(img.height))
	{
		img.style.height = (parseInt(div.style.width)/parseInt(img.width))*parseInt(img.height);
		img.style.width = div.style.width;
	}
	else
	{
		img.style.width = (parseInt(div.style.height)/parseInt(img.height))*parseInt(img.width);
		img.style.height = div.style.height;
	}
}
function QStartbar ()
{
	this.div = document.createElement ("div");
	this.div.id = "startbarDiv";
	this.startbarStyle = "margin:0px;padding:0px;position:absolute;left:0px;top:" + Qwindows.mainH + "px;width:" + Qwindows.startbarW + "px;height:" + Qwindows.barH + "px;background-color:" + Qwindows.BackColor + ";background-image:url(" + Qwindows.path + "startbar.jpg);background-position: left top;background-repeat:no-repeat;";
	this.div.style.cssText = this.startbarStyle;
	this.starStr = "<div id=\"starbarDiv_star\" style=\"margin:0px;padding:0px;position:absolute;left:0px;top:0;width:76; height:28;\"></div>";
	this.hidAllQWinStr = "<div id=\"starbarDiv_hidAllQWin\" style=\"position:absolute;left:91px;top:4;height:17px !important;>height:14px !important;	height:14px;width:17px !important;>width:19px !important;width:19px;\" onclick=\"Qwindows.hidAllQWin();\" onmousedown='fSetBorderMouseDown(this)' onmouseover='fSetBorderMouseOver(this)' onmouseout='fSetBorderMouseOut(this)'></div>";
	this.div.innerHTML = this.starStr + this.hidAllQWinStr;
}
function QWorkbar ()
{
	this.div = document.createElement ("div");
	this.div.id = "workbarDiv";
	this.WorkbarStyle = "position:absolute;left:" + Qwindows.startbarW + "px;top:" + Qwindows.mainH + "px;width:" + Qwindows.workbarW + "px;height:" + Qwindows.barH + "px;background-color:" + Qwindows.BackColor + ";background-image:url(" + Qwindows.path + "barBg.jpg);background-position: left top;background-repeat:repeat;font-size:12px;font-weight:550;text-align:left;color:#ffffff;word-break:break-all;overflow-x:hidden;overflow-y:auto;-moz-user-select: none;"
	+ "scrollbar-arrow-color: #183376; scrollbar-track-color:#346bbd;scrollbar-face-color:#2954a2;scrollbar-shadow-color:#346bbd;scrollbar-darkshadow-color:#346bbd;scrollbar-3dlight-color:#346bbd;scrollbar-highlight-color:#346bbd;";
	this.div.style.cssText = this.WorkbarStyle;
	if(coos.browser.msie)
	{
		this.div.onselectstart = function(){return false;};
	}
	this.addTab = function (winID)
	{
		var win = Qwindows.getWindow (winID);
		var tab = document.createElement ("div");
		tab.id = "tab_" + winID;
		this.tabStyle = "float:left;clear:none;position:relative;width:" + Qwindows.worktabW + "px;height:22px;background-image:url(" + Qwindows.path + "tabBg.jpg);background-position: left top;background-repeat:repeat-x;text-align:center;margin-top:3px;margin-right:2px;padding-top:5px;border:1px solid #8abef8;cursor:default;";
		this.tabStyleFirefox = "float:left;clear:none;position:relative;width:" + Qwindows.worktabW + "px;height:16px;background-image:url(" + Qwindows.path + "tabBg.jpg);background-position: left top;background-repeat:repeat-x; text-align:center;margin-top:3px;margin-right:2px;padding-top:4px;border:1px solid #8abef8;cursor:default;";
		if(coos.browser.msie)
		{
			tab.style.cssText = this.tabStyle;
		}
		else
		{
			tab.style.cssText = this.tabStyleFirefox;
		}
		tab.innerHTML = win.title.intercept(10);
		tab.onclick = function ()
		{
			QWorkbar.nowtabBg(tab.id);
			var win = Qwindows.getWindow (this.id.substring(4));
			if (win.isOpen () && win.isTop())
				win.hide ();
			else
				win.show ();
			return false;
		}
		this.div.appendChild (tab);
		QWorkbar.nowtabBg(tab.id);
	}
	this.deleteTab = function (winID)
	{
		var tab = document.getElementById ("tab_" + winID);
		Qwindows.windows.remove(winID);
		var topwinid = Qwindows.getTopWin();
		if(topwinid != "")
		{
			var win = Qwindows.getWindow(topwinid);
			win.toTop();
		}
		else
		{
			Qwindows.tabid = "";
		}
		if (tab != null)
		{
			tab.parentNode.removeChild (tab);
		}
	}
}
QWorkbar.nowtabBg = function(tabid)
{
	var bgimage = $(tabid).style.backgroundImage;
	if(bgimage.indexOf("nowtabBg.jpg") == -1)
	{
		if(Qwindows.tabid != "")
		{
			$(Qwindows.tabid).style.backgroundImage = bgimage.replace("nowtabBg.jpg","tabBg.jpg");
		}
		$(tabid).style.backgroundImage = bgimage.replace("tabBg.jpg","nowtabBg.jpg");
	}
	Qwindows.tabid = tabid;
}
function QSysbar ()
{
	this.div = document.createElement ("div");
	this.div.id = "sysbarDiv";
	this.sysbarStyle = "margin:0px;padding:0px;position:absolute;left:" + parseInt(Qwindows.startbarW + Qwindows.workbarW) + "px;top:" + Qwindows.mainH + "px;width:" + Qwindows.sysbarW + "px;height:" + Qwindows.barH + "px;background-color:" + Qwindows.BackColor + ";background-image:url(" + Qwindows.path + "barBg.jpg);background-position: left top;background-repeat:repeat-x;";
	this.div.style.cssText = this.sysbarStyle;
	this.addIcon = function (imgURL,tip)
	{
		var img = document.createElement ("img");
		this.imgStyle = "width:23;height:28;";
		img.style.cssText = this.imgStyle;
		img.src = imgURL;
		this.div.appendChild (img);
	}
	this.deleteIcon = function (imgURL)
	{
	}
}
function QAlphaWin (type,target,title,logo,url,left,top,width,height)
{
	this.type   = type;
	this.id     = "win_" + target;
	this.title  = title;
	this.logo   = logo;
	this.url    = url;
	this.left   = left;
	this.top    = top;
	this.width  = width;
	this.height = height;
	this.winx   = 10;
	this.winy   = 10;
	this.div = document.createElement ("div");
	this.div.id = this.id;
	Qwindows.winIndex = Qwindows.winIndex + 1;
	this.QWinStyle = "margin:0px;padding:0px;position:absolute;left:" + this.left + "px;top:" + this.top + "px;width:" + this.width + "px;height:" + this.height + "px;z-index:" + Qwindows.winIndex + ";overflow:hidden;border:1px solid #9abbe8;";
	this.div.style.cssText = this.QWinStyle;
	this.titleid     = this.id + "_title";
	this.logoid      = this.id + "_logo";
	this.winttid     = this.id + "_wintt";
	this.pageDivid   = this.id + "_page";
	this.maximageid  = this.id + "_imgmax";
	this.closeid     = this.id + "_closeimg";
	this.leftDivid   = this.id + "_left";
	this.topDivid    = this.id + "_top";
	this.rightDivid  = this.id + "_right";
	this.bottomDivid = this.id + "_bottom";
	if(coos.browser.msie)
	{
		this.pageH    = parseInt(this.div.style.height)-21-4;
		this.pageW    = parseInt(this.div.style.width)-8;
		this.leftH       = parseInt(this.div.style.height)-6;
	}
	else
	{
		this.pageH    = parseInt(this.div.style.height)-21-4;
		this.pageW    = parseInt(this.div.style.width)-8;
		this.leftH       = parseInt(this.div.style.height)-4;
	}
	var innerHTMLStr = "<div id=\"" + this.titleid + "\" style=\"position:absolute;left:0px;top:0px;width:" + this.div.style.width + ";height:21px;cursor:default;line-height:100%;background-color:#9cc4e9;\">"
	+ "<div id=\"" + this.logoid + "\"  style=\"position:absolute;left:5px;top:2px;width:18px;height:18px;background:url( "+ this.logo + ")  no-repeat !important;background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + this.logo + ", sizingmethod=scale);-moz-user-select: none;\" onselectstart = \"return false;\"></div>"
	+ "<div id=\"" + this.winttid + "\"  style=\"display:block;position:absolute;left:25px;top:2px;width:180px;height:18px;white-space:nowrap;text-align:left;padding-top:3px;font-size:12px;color:#000000;font-weight:550;overflow:hidden;-moz-user-select: none;\" onselectstart = \"return false;\">"
	+ this.title.intercept(30) + "</div>"
	var imgdiv = "";
	if(type.toLowerCase() == "quickalpha")
	{
		imgdiv = "<div id=\"" + this.id + "_imgdv\"  style=\"position:absolute;right:6px;top:3px;width:95px;height:15px;text-align:right;cursor:default;\">"
		+ "<img src=\"" + Qwindows.path + "reload.jpg\" id=\"" + this.id + "_imgrel\"  width=\"15\" height=\"14\" onclick='Qwindows.getWindow(\"" + this.id + "\").reload()' style=\"margin-right: 2px;\" onmouseover='fSetAlphaMouseOver(this)' onmouseout='fSetAlphaMouseOut(this)'/>"
		+ "	</div>"
		+ "</div>";
	}
	else
	{
		imgdiv = "<div id=\"" + this.id + "_imgdv\"  style=\"position:absolute;right:6px;top:3px;width:95px;height:15px;text-align:right;cursor:default;\">"
		+ "<img src=\"" + Qwindows.path + "reload.jpg\" id=\"" + this.id + "_imgrel\"  width=\"15\" height=\"14\" onclick='Qwindows.getWindow(\"" + this.id + "\").reload()' style=\"margin-right: 2px;\" onmouseover='fSetAlphaMouseOver(this)' onmouseout='fSetAlphaMouseOut(this)'/>"
		+ "<img src=\"" + Qwindows.path + "minimize.jpg\" id=\"" + this.id + "_imgmin\"  width=\"15\" height=\"14\" onclick='Qwindows.getWindow(\"" + this.id + "\").min()' style=\"margin-right: 2px;\" onmouseover='fSetAlphaMouseOver(this)' onmouseout='fSetAlphaMouseOut(this)'/>"
		+ "<img src=\"" + Qwindows.path + "maximize.jpg\" id=\"" + this.maximageid + "\" width=\"15\" height=\"14\" onclick='Qwindows.getWindow(\"" + this.id + "\").exchange()' style=\"margin-right: 2px;\" onmouseover='fSetAlphaMouseOver(this)' onmouseout='fSetAlphaMouseOut(this)'/>"
		+ "<img src=\"" + Qwindows.path + "close.jpg\" id=\"" + this.closeid + "\" width=\"15\" height=\"14\" onclick='Qwindows.getWindow(\"" + this.id + "\").close()' style=\"margin-right: 2px;\" onmouseover='fSetAlphaMouseOver(this)' onmouseout='fSetAlphaMouseOut(this)'/>"
		+ "	</div>"
		+ "</div>";
	}
	var Alpha = "<div id=\"" + this.pageDivid + "\" style=\"margin:0px;padding:0px;position:absolute;left:3px;top:21px; width:" + this.pageW + "px;height:" + this.pageH +"px;text-align:center;border:1px solid #9abbe8;overflow:auto;\"></div>";
	var leftDiv = "<div id=\"" + this.leftDivid + "\" style=\"position:absolute;left:0px;top:2px; width:3px;height:" + this.leftH +"px;background-color:#9cc4e9;\"></div>";
	var rightDiv = "<div id=\"" + this.rightDivid + "\" style=\"position:absolute;right:0px;top:2px; width:3px;height:" + this.leftH +"px;background-color:#9cc4e9;\"></div>";
	var topDiv = "<div id=\"" + this.topDivid + "\" style=\"position:absolute;left:0px;top:0px; width:"+ this.div.style.width + ";height:2px;background-color:#9cc4e9;\"></div>";
	var bottomDiv = "<div id=\"" + this.bottomDivid + "\" style=\"margin:0px;padding:0px;position:absolute;left:0px;top:" + this.leftH +"px; width:"+ this.div.style.width + ";height:4px;background-color:#9cc4e9;\"></div>";
	this.div.innerHTML = leftDiv + rightDiv + topDiv + bottomDiv + innerHTMLStr + imgdiv + Alpha;
	this.setTitle = function (title)
	{
		$(this.winttid).innerHTML = title.intercept(30);
		this.title     = title;
	}
	this.setLogo = function (imgurl)
	{
		var css = "position:absolute;left:5px;top:2px;width:18px;height:18px;background:url( "
		+ imgurl + ")  no-repeat !important;background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="
		+ imgurl + ", sizingmethod=scale);-moz-user-select: none;";
		$(this.logoid).style.cssText = css;
	}
	this.setSrc = function (url)
	{
		Ajax.sendGetRequest(url, true, "Qwindows.getWindow(\""+ this.id + "\").setContent (ME.responseText)");
	}
	this.setContent = function(data)
	{
		$(this.pageDivid).innerHTML = data;
	}
	this.reload = function()
	{
		this.setSrc(this.url);
	}
	this.isOpen = function ()
	{
		return (this.div.style.display == "");
	}
	this.isTop = function ()
	{
		return (parseInt (this.div.style.zIndex) >= Qwindows.winIndex);
	}
	this.toTop = function()
	{
		if(!this.isTop())
		{
			Qwindows.winIndex = Qwindows.winIndex + 1;
			this.div.style.zIndex = Qwindows.winIndex;
			var tabid = "tab_" + this.div.id;
			QWorkbar.nowtabBg(tabid);
		}
		if(Qwindows.preTopDiv != null)
		{
			var preid = Qwindows.preTopDiv.id;
			$(preid + "_title").style.backgroundColor = "#c5daef";
			$(preid + "_left").style.backgroundColor = "#c5daef";
			$(preid + "_top").style.backgroundColor = "#c5daef";
			$(preid + "_right").style.backgroundColor = "#c5daef";
			$(preid + "_bottom").style.backgroundColor = "#c5daef";
		}
		$(this.titleid).style.backgroundColor = "#9cc4e9";
		$(this.leftDivid).style.backgroundColor = "#9cc4e9";
		$(this.topDivid).style.backgroundColor = "#9cc4e9";
		$(this.rightDivid).style.backgroundColor = "#9cc4e9";
		$(this.bottomDivid).style.backgroundColor = "#9cc4e9";
		Qwindows.preTopDiv = this.div;
	}
	this.hide = function ()
	{
		this.div.style.display = "none";
	}
	this.show = function ()
	{
		this.div.style.display = "";
		this.toTop();
	}
	this.max = function ()
	{
		this.div.style.left	= "0px";
		this.div.style.top	= "0px";
		this.div.style.width  = Qwindows.mainW + "px";
		this.div.style.height = Qwindows.mainH + "px";
		$(this.titleid).style.width = this.div.style.width;
		if(coos.browser.msie)
		{
			$(this.pageDivid).style.height = (parseInt(this.div.style.height) - 21 - 4) + "px";
			$(this.pageDivid).style.width  = (parseInt(this.div.style.width)-8) + "px";
			var leftH = (parseInt(this.div.style.height)-6) + "px";
			$(this.leftDivid).style.height = leftH;
			$(this.rightDivid).style.height = leftH;
			$(this.bottomDivid).style.top = leftH;
			$(this.bottomDivid).style.width = this.div.style.width;
		}
		else
		{
			$(this.pageDivid).style.height = (parseInt(this.div.style.height) - 21 - 4) + "px";
			$(this.pageDivid).style.width = (parseInt(this.div.style.width)-8) + "px";
			var leftH = (parseInt(this.div.style.height)-4) + "px";
			$(this.leftDivid).style.height = leftH;
			$(this.rightDivid).style.height = leftH;
			$(this.bottomDivid).style.top = leftH;
			$(this.bottomDivid).style.width = this.div.style.width;
		}
		if($(this.maximageid))
		$(this.maximageid).src = Qwindows.path + "restore.jpg";
	}
	this.normal = function ()
	{
		this.div.style.left = this.winx;
		this.div.style.top	= this.winy;
		this.div.style.width = this.width + "px";
		this.div.style.height= this.height + "px";
		$(this.titleid).style.width = this.div.style.width;
		if(coos.browser.msie)
		{
			$(this.pageDivid).style.height = (parseInt(this.div.style.height) - 21 - 4) + "px";
			$(this.pageDivid).style.width  = (parseInt(this.div.style.width)-8) + "px";
			var leftH = (parseInt(this.div.style.height)-6) + "px";
			$(this.leftDivid).style.height = leftH;
			$(this.rightDivid).style.height = leftH;
			$(this.bottomDivid).style.top = leftH;
			$(this.bottomDivid).style.width = this.div.style.width;
		}
		else
		{
			$(this.pageDivid).style.height = (parseInt(this.div.style.height) - 21 - 4) + "px";
			$(this.pageDivid).style.width = (parseInt(this.div.style.width)-8) + "px";
			var leftH = (parseInt(this.div.style.height)-4) + "px";
			$(this.leftDivid).style.height = leftH;
			$(this.rightDivid).style.height = leftH;
			$(this.bottomDivid).style.top = leftH;
			$(this.bottomDivid).style.width = this.div.style.width;
		}
		if($(this.maximageid))
		$(this.maximageid).src = Qwindows.path + "maximize.jpg";
	}
	this.min = function ()
	{
		this.hide ();
	}
	this.exchange = function ()
	{
		if (parseInt (this.div.style.width) == Qwindows.mainW)
		{
			this.normal ();
		}
		else
		{
			this.winx = this.div.style.left;
			this.winy = this.div.style.top;
			this.max ();
		}
	}
	this.close = function ()
	{
		Qwindows.preTopDiv = null;
		this.div.parentNode.removeChild (this.div);
		Qwindows.workbar.deleteTab (this.id);
		return false;
	}
}
function QWin (type,target,title,logo,url,left,top,width,height)
{
	this.type   = type;
	this.id     = "win_" + target;
	this.title  = title;
	this.logo   = logo;
	this.url    = url;
	this.left   = left;
	this.top    = top;
	this.width  = width;
	this.height = height;
	this.winx   = 10;
	this.winy   = 10;
	this.div = document.createElement ("div");
	this.div.id = this.id;
	Qwindows.winIndex = Qwindows.winIndex + 1;
	this.QWinStyle = "margin:0px;padding:0px;position:absolute;left:" + this.left + "px;top:" + this.top + "px;width:" + this.width + "px;height:" + this.height + "px;z-index:" + Qwindows.winIndex + ";overflow:hidden;border:1px solid #9abbe8;";
	this.div.style.cssText = this.QWinStyle;
	this.titleid     = this.id + "_title";
	this.logoid      = this.id + "_logo";
	this.winttid     = this.id + "_wintt";
	this.pageDivid   = this.id + "_page";
	this.maximageid  = this.id + "_imgmax";
	this.closeid     = this.id + "_closeimg";
	this.iframeid    = this.id + "_iframe";
	this.leftDivid   = this.id + "_left";
	this.topDivid    = this.id + "_top";
	this.rightDivid  = this.id + "_right";
	this.bottomDivid = this.id + "_bottom";
	if(coos.browser.msie)
	{
		this.iframeH    = parseInt(this.div.style.height)-21-6;
		this.iframeW    = parseInt(this.div.style.width)-9;
		this.leftH       = parseInt(this.div.style.height)-6;
	}
	else
	{
		this.iframeH    = parseInt(this.div.style.height)-21-4;
		this.iframeW    = parseInt(this.div.style.width)-8;
		this.leftH       = parseInt(this.div.style.height)-4;
	}
	this.loadingid  = this.id + "_loading";
	this.loadingW   = (parseInt(this.iframeW)-210)/2;
	this.loadingH   = (parseInt(this.iframeH)-28)/2;
	var innerHTMLStr = "<div id=\"" + this.titleid + "\" style=\"position:absolute;left:0px;top:0px;width:" + this.div.style.width + ";height:21px;cursor:default;line-height:100%;background-color:#9cc4e9;\">"
	+ "<div id=\"" + this.logoid + "\"  style=\"position:absolute;left:5px;top:2px;width:18px;height:18px;background:url( "+ this.logo + ")  no-repeat !important;background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + this.logo + ", sizingmethod=scale);-moz-user-select: none;\" onselectstart = \"return false;\"></div>"
	+ "<div id=\"" + this.winttid + "\"  style=\"display:block;position:absolute;left:25px;top:2px;width:180px;height:18px;white-space:nowrap;text-align:left;padding-top:3px;font-size:12px;color:#000000;font-weight:550;overflow:hidden;-moz-user-select: none;\" onselectstart = \"return false;\">"
	+ this.title.intercept(30) + "</div>";
	var imgdiv = "";
	if(type.toLowerCase() == "quick")
	{
		imgdiv = "<div id=\"" + this.id + "_imgdv\"  style=\"position:absolute;right:6px;top:3px;width:95px;height:15px;text-align:right;cursor:default;\">"
		+ "<img src=\"" + Qwindows.path + "reload.jpg\" id=\"" + this.id + "_imgrel\"  width=\"15\" height=\"14\" onclick='Qwindows.getWindow(\"" + this.id + "\").reload()' style=\"margin-right: 2px;\" onmouseover='fSetAlphaMouseOver(this)' onmouseout='fSetAlphaMouseOut(this)'/>"
		+ "	</div>"
		+ "</div>";
	}
	else
	{
		imgdiv = "<div id=\"" + this.id + "_imgdv\"  style=\"position:absolute;right:6px;top:3px;width:95px;height:15px;text-align:right;cursor:default;\">"
		+ "<img src=\"" + Qwindows.path + "reload.jpg\" id=\"" + this.id + "_imgrel\"  width=\"15\" height=\"14\" onclick='Qwindows.getWindow(\"" + this.id + "\").reload()' style=\"margin-right: 2px;\" onmouseover='fSetAlphaMouseOver(this)' onmouseout='fSetAlphaMouseOut(this)'/>"
		+ "<img src=\"" + Qwindows.path + "minimize.jpg\" id=\"" + this.id + "_imgmin\"  width=\"15\" height=\"14\" onclick='Qwindows.getWindow(\"" + this.id + "\").min()' style=\"margin-right: 2px;\" onmouseover='fSetAlphaMouseOver(this)' onmouseout='fSetAlphaMouseOut(this)'/>"
		+ "<img src=\"" + Qwindows.path + "maximize.jpg\" id=\"" + this.maximageid + "\" width=\"15\" height=\"14\" onclick='Qwindows.getWindow(\"" + this.id + "\").exchange()' style=\"margin-right: 2px;\" onmouseover='fSetAlphaMouseOver(this)' onmouseout='fSetAlphaMouseOut(this)'/>"
		+ "<img src=\"" + Qwindows.path + "close.jpg\" id=\"" + this.closeid + "\" width=\"15\" height=\"14\" onclick='Qwindows.getWindow(\"" + this.id + "\").close()' style=\"margin-right: 2px;\" onmouseover='fSetAlphaMouseOver(this)' onmouseout='fSetAlphaMouseOut(this)'/>"
		+ "	</div>"
		+ "</div>";
	}
	var IEiframe = "<div id=\"" + this.id + "_page" + "\" style=\"margin:0px;padding:0px;position:absolute;left:3px;top:21px; width:" + this.iframeW + "px;height:" + this.iframeH +"px;text-align:center;background-color:#ffffff;border:1px solid #9abbe8;\">"
	+ "<div id=\"" + this.loadingid + "\"  style=\"position: absolute;left:" + this.loadingW + "px;top:" + this.loadingH + "px;white-space:nowrap;color: #FF0000;font-size:14px;\"><img src=\"" + Qwindows.path + "loading.gif\" width=\"16\" height=\"16\" /> 正在加载页面，请稍后......</div>"
	+ "<iframe id=\"" + this.iframeid + "\" src=\"" + url + "\" frameBorder=\"0\"  scrolling=\"auto\" style=\"width:" + this.iframeW + "px;height:" + this.iframeH +"px; display:;\" onreadystatechange=\"Qwindows.stateChangeIE('" + this.iframeid + "','" + this.loadingid + "')\"></iframe>"
	+ "</div>";
	var Firefoxiframe = "<div id=\"" + this.id + "_page" + "\" style=\"margin:0px;padding:0px;position:absolute;left:3px;top:21px; width:" + this.iframeW + "px;height:" + this.iframeH +"px;text-align:center;background-color:#ffffff;border:1px solid #9abbe8;\">"
	+ "<div id=\"" + this.loadingid + "\"  style=\"position: absolute;left:" + this.loadingW + "px;top:" + this.loadingH + "px;white-space:nowrap;color: #FF0000;font-size:14px;\"><img src=\"" + Qwindows.path + "loading.gif\" width=\"16\" height=\"16\" /> 正在加载页面，请稍后......</div>"
	+ "<iframe id=\"" + this.iframeid + "\" src=\"" + url + "\" frameBorder=\"0\"  scrolling=\"auto\" style=\"width:" + this.iframeW + "px;height:" + this.iframeH +"px; display:none;\"  onload=\"Qwindows.stateChangeFirefox('" + this.iframeid + "','" + this.loadingid + "')\"></iframe>"
	+ "</div>";
	var leftDiv = "<div id=\"" + this.leftDivid + "\" style=\"position:absolute;left:0px;top:2px; width:3px;height:" + this.leftH +"px;background-color:#9cc4e9;\"></div>";
	var rightDiv = "<div id=\"" + this.rightDivid + "\" style=\"position:absolute;right:0px;top:2px; width:3px;height:" + this.leftH +"px;background-color:#9cc4e9;\"></div>";
	var topDiv = "<div id=\"" + this.topDivid + "\" style=\"position:absolute;left:0px;top:0px; width:"+ this.div.style.width + ";height:2px;background-color:#9cc4e9;\"></div>";
	var bottomDiv = "<div id=\"" + this.bottomDivid + "\" style=\"margin:0px;padding:0px;position:absolute;left:0px;top:" + this.leftH +"px; width:"+ this.div.style.width + ";height:4px;background-color:#9cc4e9;\"></div>";
	if(coos.browser.msie)
	{
		this.div.innerHTML = leftDiv + rightDiv + topDiv + bottomDiv + innerHTMLStr + imgdiv + IEiframe;
	}
	else
	{
		this.div.innerHTML = leftDiv + rightDiv + topDiv + bottomDiv + innerHTMLStr + imgdiv + Firefoxiframe;
	}
	this.isLoad = function()
	{
		if($(this.iframeid).contentWindow)
		return true;
		else
		return false;
	}
	this.setSrc = function (theURL)
	{
		$(this.iframeid).src = theURL;
		this.url = theURL;
	}
	this.setTitle = function (title)
	{
		$(this.winttid).innerHTML = title.intercept(30);
		this.title     = title;
	}
	this.setLogo = function (imgurl)
	{
		var css = "position:absolute;left:5px;top:2px;width:18px;height:18px;background:url( "
		+ imgurl + ")  no-repeat !important;background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="
		+ imgurl + ", sizingmethod=scale);-moz-user-select: none;";
		$(this.logoid).style.cssText = css;
	}
	this.reload = function()
	{
		$(this.iframeid).src = this.url;
	}
	this.isOpen = function ()
	{
		return (this.div.style.display == "");
	}
	this.isTop = function ()
	{
		return (parseInt (this.div.style.zIndex) >= Qwindows.winIndex);
	}
	this.toTop = function()
	{
		if(!this.isTop())
		{
			Qwindows.winIndex = Qwindows.winIndex + 1;
			this.div.style.zIndex = Qwindows.winIndex;
			var tabid = "tab_" + this.div.id;
			QWorkbar.nowtabBg(tabid);
		}
		if(Qwindows.preTopDiv != null)
		{
			var preid = Qwindows.preTopDiv.id;
			$(preid + "_title").style.backgroundColor = "#c5daef";
			$(preid + "_left").style.backgroundColor = "#c5daef";
			$(preid + "_top").style.backgroundColor = "#c5daef";
			$(preid + "_right").style.backgroundColor = "#c5daef";
			$(preid + "_bottom").style.backgroundColor = "#c5daef";
		}
		$(this.titleid).style.backgroundColor = "#9cc4e9";
		$(this.leftDivid).style.backgroundColor = "#9cc4e9";
		$(this.topDivid).style.backgroundColor = "#9cc4e9";
		$(this.rightDivid).style.backgroundColor = "#9cc4e9";
		$(this.bottomDivid).style.backgroundColor = "#9cc4e9";
		Qwindows.preTopDiv = this.div;
	}
	this.hide = function ()
	{
		this.div.style.display = "none";
	}
	this.show = function ()
	{
		this.div.style.display = "";
		this.toTop();
	}
	this.max = function ()
	{
		this.div.style.left	= "0px";
		this.div.style.top	= "0px";
		this.div.style.width  = Qwindows.mainW + "px";
		this.div.style.height = Qwindows.mainH + "px";
		$(this.titleid).style.width = this.div.style.width;
		if(coos.browser.msie)
		{
			$(this.pageDivid).style.height = (parseInt(this.div.style.height) - 21 - 6) + "px";
			$(this.pageDivid).style.width  = (parseInt(this.div.style.width)-9) + "px";
			var leftH = (parseInt(this.div.style.height)-6) + "px";
			$(this.leftDivid).style.height = leftH;
			$(this.rightDivid).style.height = leftH;
			$(this.bottomDivid).style.top = leftH;
			$(this.bottomDivid).style.width = this.div.style.width;
			$(this.iframeid).style.height = $(this.pageDivid).style.height;
			$(this.iframeid).style.width = $(this.pageDivid).style.width;
		}
		else
		{
			$(this.pageDivid).style.height = (parseInt(this.div.style.height) - 21 - 4) + "px";
			$(this.pageDivid).style.width  = (parseInt(this.div.style.width)-8) + "px";
			var leftH = (parseInt(this.div.style.height)-4) + "px";
			$(this.leftDivid).style.height = leftH;
			$(this.rightDivid).style.height = leftH;
			$(this.bottomDivid).style.top = leftH;
			$(this.bottomDivid).style.width = this.div.style.width;
			$(this.iframeid).style.height = $(this.pageDivid).style.height;
			$(this.iframeid).style.width = $(this.pageDivid).style.width;
		}
		if($(this.maximageid))
		$(this.maximageid).src = Qwindows.path + "restore.jpg";
	}
	this.normal = function ()
	{
		this.div.style.left = this.winx;
		this.div.style.top	= this.winy;
		this.div.style.width = this.width + "px";
		this.div.style.height= this.height + "px";
		$(this.titleid).style.width = this.div.style.width;
		if(coos.browser.msie)
		{
			$(this.pageDivid).style.height = (parseInt(this.div.style.height) - 21 - 6) + "px";
			$(this.pageDivid).style.width  = (parseInt(this.div.style.width)-9) + "px";
			var leftH = (parseInt(this.div.style.height)-6) + "px";
			$(this.leftDivid).style.height = leftH;
			$(this.rightDivid).style.height = leftH;
			$(this.bottomDivid).style.top = leftH;
			$(this.bottomDivid).style.width = this.div.style.width;
			$(this.iframeid).style.height = $(this.pageDivid).style.height;
			$(this.iframeid).style.width = $(this.pageDivid).style.width;
		}
		else
		{
			$(this.pageDivid).style.height = (parseInt(this.div.style.height) - 21 - 4) + "px";
			$(this.pageDivid).style.width  = (parseInt(this.div.style.width)-8) + "px";
			var leftH = (parseInt(this.div.style.height)-4) + "px";
			$(this.leftDivid).style.height = leftH;
			$(this.rightDivid).style.height = leftH;
			$(this.bottomDivid).style.top = leftH;
			$(this.bottomDivid).style.width = this.div.style.width;
			$(this.iframeid).style.height = $(this.pageDivid).style.height;
			$(this.iframeid).style.width = $(this.pageDivid).style.width;
		}
		if($(this.maximageid))
		$(this.maximageid).src = Qwindows.path + "maximize.jpg";
	}
	this.min = function ()
	{
		this.hide ();
	}
	this.exchange = function ()
	{
		if (parseInt (this.div.style.width) == Qwindows.mainW)
		{
			this.normal ();
		}
		else
		{
			this.winx = this.div.style.left;
			this.winy = this.div.style.top;
			this.max ();
		}
	}
	this.close = function ()
	{
		Qwindows.preTopDiv = null;
		this.div.parentNode.removeChild (this.div);
		Qwindows.workbar.deleteTab (this.id);
		return false;
	}
}
Qwindows.stateChangeIE = function(iframeid,loadingid)
{
	if(!$(iframeid))
	{
		if($(loadingid))
			$(loadingid).style.display = "none";
		return;
	}
	var state = $(iframeid).readyState;
	if(state == "complete" ||state == "interactive")
	{
		$(loadingid).style.display = "none";
		$(iframeid).style.display = "";
	}
   	else
	{
    	setTimeout("Qwindows.stateChangeIE('" + iframeid + "','" + loadingid + "')",500);
	}
}
Qwindows.stateChangeFirefox = function(iframeid,loadingid)
{
	if(!$(iframeid))
	{
		if($(loadingid))
			$(loadingid).style.display = "none";
		return;
	}
	$(loadingid).style.display = "none";
	$(iframeid).style.display = "";
}
Qwindows.init = function (w, h,json)
{
	Qwindows.onresize();
	if(w == 0 || w == "" || w == null)
	{
		Qwindows.mainW = Qwindows.getwinWidth();
	}
	else
	{
		Qwindows.mainW	= w;
	}
	if(h == 0 || h == "" || h == null)
	{
		Qwindows.mainH = Qwindows.getwinHeight()-Qwindows.barH;
	}
	else
	{
		Qwindows.mainH	= h-Qwindows.barH;
	}
	Qwindows.workbarW	= Qwindows.mainW-Qwindows.startbarW-Qwindows.sysbarW;
	Qwindows.main		= new QMain ();
	Qwindows.startbar	= new QStartbar ();
	Qwindows.workbar	= new QWorkbar ();
	Qwindows.sysbar		= new QSysbar ();
	document.body.appendChild (Qwindows.main.div);
	document.body.appendChild (Qwindows.startbar.div);
	document.body.appendChild (Qwindows.workbar.div);
	document.body.appendChild (Qwindows.sysbar.div);
	Qwindows.paintDesks(json);
}
Qwindows.paintDesks = function(json)
{
	var data = null;
	if(typeof(json)!="object")
	{
		data = eval('(' + json + ')');
	}
	else
	{
		data = json;
	}
	var len = data.length;
	for(var i = 0; i < len; i++)
	{
		var type   = data[i].type;
		var target = data[i].target;
		var title  = data[i].title;
		var logo   = data[i].logo;
		var left   = data[i].left;
		var top    = data[i].top;
		var action = data[i].action;
		var desk = new paintDesk(type,target,title,logo,left,top,action);
		Qwindows.desks.put(desk.id,desk);
	}
}
function paintDesk(type,target,title,logo,left,top,action)
{
	this.type    = type;
	this.id      = "desk_" + target;
	this.title   = title;
	this.logo    = logo;
	this.left    = left;
	this.top     = top;
	if(type.toLowerCase() == "quick")
	{
		this.width   = 32;
		this.height  = 27;
		if(left == 0) this.left = parseInt(Qwindows.mainW) - parseInt(this.width) - 30;
		if(top == 0) this.top = 10;
		if(logo == "" || logo == null) this.logo = Qwindows.path + "down.png";
		var data = null;
		if(typeof(action)!="object")
		{
			data = eval('(' + action + ')');
		}
		else
		{
			data = action;
		}
		var len = data.length;
		for(var i = 0; i < len; i++)
		{
			data[i].target = target;
			if(data[i].width == 0 || data[i].width == null) data[i].width = Qwindows.winW;
			if(data[i].height == 0 || data[i].height == null) data[i].height = Qwindows.winH;
			data[i].left = parseInt(this.left) - parseInt(data[i].width) + 5;
			data[i].top = parseInt(this.top) + parseInt(this.height) - 8;
		}
		this.action  = data;
	}
	else
	{
		this.width   = 80;
		this.height  = 60;
		this.action  = action;
	}
	var Qaction = this.action;
	this.div     = document.createElement ("div");
	this.div.id = this.id;
	this.deskStyle = "margin:0px;padding:0px;z-index:2;position:absolute;left:" + this.left + "px;top:" + this.top + "px;width:" + this.width + "px;height:" + this.height + "px;text-align:center;";
	this.div.style.cssText = this.deskStyle;
	this.div.title = this.title;
	Qwindows.main.div.appendChild (this.div);
	var deskid     = this.div.id;
	this.titleid   = this.div.id + "_title";
	this.logoid    = this.div.id + "_tlogo";
	var logoid     = this.logoid;
	if(type.toLowerCase() == "quick")
	{
		this.logodiv    = document.createElement ("div");
		this.logodiv.id = this.logoid;
		this.logoStyle  = "position:absolute; left:0px; top:0px;width:32px;height:27px;background:url( "+ this.logo + ")  no-repeat !important;background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + this.logo + ", sizingmethod=scale);-moz-user-select: none;";
		this.logodiv.style.cssText = this.logoStyle;
		this.div.appendChild (this.logodiv);
	}
	else
	{
		this.logodiv    = document.createElement ("div");
		this.logodiv.id = this.logoid;
		this.logoStyle  = "position:absolute; left:24px; top:0px;width:32px;height:27px;background:url( "+ this.logo + ")  no-repeat !important;background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=" + this.logo + ", sizingmethod=scale);-moz-user-select: none;";
		this.logodiv.style.cssText = this.logoStyle;
		this.div.appendChild (this.logodiv);
		this.titlediv   = document.createElement ("div");
		this.titlediv.id = this.titleid;
		this.titleStyle = "position:absolute; left:0px; top:30px;width:" + this.width + "px;height:30px; color:#FFFFFF; font-size:12px;font-weight:550;text-align:center;word-break:break-all;overflow:visible;cursor:default;";
		this.titlediv.style.cssText = this.titleStyle;
		this.titlediv.innerHTML = this.title.intercept(24);
		this.div.appendChild (this.titlediv);
	}
	this.setTitle = function (title)
	{
		if(!$(this.titleid)) return;
		$(this.titleid).innerHTML = title.intercept(24);
		this.title     = title;
		this.div.title = title;
	}
	this.setLogo = function (imgurl)
	{
		var css = "";
		if(this.type.toLowerCase() == "quick")
		{
			css = "position:absolute; left:0px; top:0px;width:32px;height:27px;background:url( "
			+ imgurl + ")  no-repeat !important;background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="
			+ imgurl + ", sizingmethod=scale);-moz-user-select: none;";
		}
		else
		{
			css = "position:absolute; left:24px; top:0px;width:32px;height:27px;background:url( "
			+ imgurl + ")  no-repeat !important;background-image:none;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="
			+ imgurl + ", sizingmethod=scale);-moz-user-select: none;";
		}
		$(this.logoid).style.cssText = css;
	}
	this.close = function ()
	{
		Qwindows.desks.remove(this.id);
		this.div.parentNode.removeChild (this.div);
	}
	if(type.toLowerCase() == "quick")
	{
		this.div.onclick = function(){configWindow(Qaction);return false;};
	}
	else
	{
		if(coos.browser.msie)
		{
			this.div.onclick = function(){Qwindows.showDeskTitle(deskid);return false;};
			this.div.ondblclick = function(){configWindow(Qaction);return false;};
			Qwindows.dragForIE($(this.logoid));
		}
		else
		{
			this.div.onclick = function(){Qwindows.showDeskTitle(deskid);return false;};
			Qwindows.dragForFirefox($(logoid));
			EventUtil.addEventHandler(this.div,'dblclick',function(){configWindow(Qaction);});
		}
	}
}
Qwindows.getDesk = function (deskID)
{
	if(deskID.substr(0,5) == "desk_")
		return Qwindows.desks.get(deskID);
	else
		return Qwindows.windows.get ("desk_" + deskID);
}
function configWindow(action)
{
	var data = null;
	if(typeof(action)!="object")
	{
		data = eval('(' + action + ')');
	}
	else
	{
		data = action;
	}
	var len = data.length;
	for(var i = 0; i < len; i++)
	{
		var type   = data[i].type;
		var target = data[i].target;
		var title  = data[i].title;
		var logo   = data[i].logo;
		var url    = data[i].url;
		var left   = data[i].left;
		var top    = data[i].top;
		var width  = data[i].width;
		var height = data[i].height;
		Qwindows.createWindow(type,target,title,logo,url,left,top,width,height);
	}
}
Qwindows.createWindow = function (type,target,title,logo,url,left,top,width,height)
{
	Qwindows.winCount = Qwindows.winCount + 1;
	Qwindows.winPosition  = Qwindows.winPosition + 1;
	Qwindows.winL = parseInt ((Qwindows.mainW-Qwindows.winW)/10 + Qwindows.winPosition*22);
	if(Qwindows.winL >= (Qwindows.mainW-Qwindows.winW))
	{
		Qwindows.winL = parseInt (Qwindows.mainW - Qwindows.winW)/10;
		Qwindows.winPosition  = 0;
	}
	Qwindows.winT = parseInt ((Qwindows.mainH-Qwindows.winH)/10 + Qwindows.winPosition*22);
	if(Qwindows.winT >= (Qwindows.mainH-Qwindows.winH))
	{
		Qwindows.winT = parseInt (Qwindows.mainH - Qwindows.winH)/10 ;
		Qwindows.winPosition  = 0;
	}
	if(left == 0 || left == "0" || left == null) left = Qwindows.winL;
	if(top == 0 || top == "0" || top == null) top = Qwindows.winT;
	if(width == 0 || width == "0" || width == null) width = Qwindows.winW;
	if(height == 0 || height == "0" || height == null) height = Qwindows.winH;
	if(logo == "" || logo == null) logo = Qwindows.path + Qwindows.WinLogo;
	if($("win_" + target))
	{
		var win = Qwindows.getWindow("win_" + target);
		if(type.toLowerCase() == "quick" || type.toLowerCase() == "quickalpha")
		{
			win.close();
			var desk = Qwindows.getDesk("desk_" + target);
			desk.setLogo(Qwindows.path + "down.png");
			return null;
		}
		if(win.div.style.display == "none")
		{
			win.div.style.display = "";
		}
		win.toTop();
		return win;
	}
	var win = null;
	if(type.toLowerCase() == "alpha"  || type.toLowerCase() == "quickalpha")
	{
		win = new QAlphaWin (type,target,title,logo,url,left,top,width,height);
		win.setSrc(url);
	}
	else if(type.toLowerCase() == "function")
	{
		try
		{
			eval (url);
		}
		catch (e)
		{
		};
		return;
	}
	else
	{
		win = new QWin (type,target,title,logo,url,left,top,width,height);
	}
	Qwindows.windows.put (win.id, win);
	Qwindows.main.div.appendChild (win.div);
	Qwindows.workbar.addTab (win.id);
	win.toTop();
	win.div.onclick = function()
	{
		if($(win.id))
		{
			win.toTop();
		}
		return false;
	};
	$(win.titleid).ondblclick = function(){win.exchange();return false;};
	$(win.pageDivid).onclick = stopEvent;
	if(type.toLowerCase() == "maxwin")
	{
		win.max();
	}
	else if(type.toLowerCase() == "quick"  || type.toLowerCase() == "quickalpha")
	{
		var desk = Qwindows.getDesk("desk_" + target);
		desk.setLogo(Qwindows.path + "up.png");
	}
	if(coos.browser.msie)
	{
		if(!(type.toLowerCase() == "alpha" || type.toLowerCase() == "quickalpha"))
		{
			var ifr = $(win.div.id + "_iframe");
			ifr.onfocus = function(){win.toTop(); return false;};
		}
		if(!(type.toLowerCase() == "quick" || type.toLowerCase() == "quickalpha"))
		{
			Qwindows.dragForIE($(win.id + "_title"));
		}
	}
	else
	{
		if(!(type.toLowerCase() == "alpha" || type.toLowerCase() == "quickalpha"))
		{
		}
		if(!(type.toLowerCase() == "quick" || type.toLowerCase() == "quickalpha"))
		{
			Qwindows.dragForFirefox($(win.id + "_title"));
		}
	}
	return win;
}
Qwindows.getWindow = function (winID)
{
	if(winID.substr(0,4) == "win_")
		return Qwindows.windows.get (winID);
	else
		return Qwindows.windows.get ("win_" + winID);
}
function WintoTop()
{
	var Event = arguments[0];
	var obj = Event.target || Event.srcElement;
	if(obj==null || obj=="")return;
	var win = Qwindows.getWindow(obj.id);
	if(win==null || win=="")return;
	win.toTop();
}
Qwindows.createMaxWindow = function (type,target,title,logo,url,left,top,width,height)
{
	var win = Qwindows.createWindow(type,target,title,logo,url,left,top,width,height);
	win.max();
	return win;
}
Qwindows.openWindow = function(title,url,left,top,width,height)
{
	var win = Qwindows.createWindow("normal",Qwindows.winCount,title,"",url,left,top,width,height);
	return win;
}
Qwindows.getTopWin = function()
{
	var len = Qwindows.windows.size();
	var winid  = "";
	var idtmp  = "";
	var zindex = 0;
	var ztmp   = 0;
	if(len == 0) return "";
	if(len == 1) return Qwindows.windows.getKey(0);
	for(var i = 0; i < len; i++)
	{
		winid = Qwindows.windows.getKey(i);
		zindex = $(winid).style.zIndex;
		for(var j = i+1; j < len-1; j++)
		{
			idtmp = Qwindows.windows.getKey(j);
			ztmp = $(idtmp).style.zIndex;
			if(zindex < ztmp)
			continue;
		}
	}
	return winid;
}
Qwindows.showDeskTitle = function(Deskid)
{
	if(Qwindows.Deskid != "")
	{
		$(Qwindows.Deskid + "_title").innerHTML = $(Qwindows.Deskid).title.intercept(24);
	}
	$(Deskid + "_title").innerHTML = $(Deskid).title;
	Qwindows.Deskid = Deskid;
}
Qwindows.hidAllQWin = function()
{
	var len = Qwindows.windows.size();
	var winID = "";
	for(var i = 0; i < len; i++)
	{
		winID = Qwindows.windows.getKey(i);
		$(winID).style.display = "none";
	}
}
Qwindows.dragForFirefox = function(obj)
{
	EventUtil.addEventHandler(obj,'mousedown',winMousedown);
	return false;
}
function winMousedown(e)
{
	var Event = arguments[0];
	var obj = Event.target || Event.srcElement;
	if(obj==null || obj=="")return;
	var p = $(obj.id.substring(0, obj.id.length-6));
	if(!p || typeof(p)=="undefined")return;
	Qwindows.movediv = p;
	EventUtil.addEventHandler(document,'mousemove',winMousemove);
	EventUtil.addEventHandler(document,'mouseup',winMouseup);
	if(coos.browser.msie)
	{
		obj.setCapture ();
	}
	else
	{
		window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
	}
	var e = EventUtil.getEvent(e);
	Qwindows.x = EventUtil.getEventX(e);
	Qwindows.y = EventUtil.getEventY(e);
	Qwindows.x1 = Qwindows.x;
	Qwindows.y1 = Qwindows.y;
	Qwindows.moveid = obj.id;
	if(!p.style.width||!p.style.height)
	{
		p.style.width = parseInt(Qwindows.winW) + "px";
		p.style.height = parseInt(Qwindows.winH) + "px";
	}
	if(!p.style.left||!p.style.top)
	{
		p.style.left = (Qwindows.x - parseInt(p.style.width)/2) + "px";
		p.style.top  = Math.abs(Qwindows.y-10) + "px";
	}
	Qwindows.MoveWidth  = parseInt(Qwindows.mainW) - parseInt(p.style.width);
	Qwindows.MoveHeight = parseInt(Qwindows.mainH) - parseInt(p.style.height);
	if(Qwindows.MoveWidth < 0)
	{
		Qwindows.MoveWidth = 0;
	}
	if(Qwindows.MoveHeight < 0)
	{
		Qwindows.MoveHeight = 0;
	}
	if(Qwindows.getWindow(p.id))
	{
	   var win = Qwindows.getWindow(p.id);
	   win.toTop();
	}
	tempdiv = document.createElement ("div");
	tempdiv.id = "tempdiv";
	var tempStyle = "margin:0px;padding:0px;position:absolute;left:" + p.style.left + ";top:" + p.style.top + ";width:" + p.style.width + ";height:" + p.style.height + ";z-index:" + (p.style.zIndex - 1) + ";border:2px solid #9abbe8;";
	tempdiv.style.cssText = tempStyle;
	document.body.appendChild(tempdiv);
	e.returnValue = false;
	return false;
}
function winMousemove(e)
{
	var Event = arguments[0];
	var obj = Event.target || Event.srcElement;
	if(obj==null || obj=="")return;
	var tempdiv = $("tempdiv");
	var e = EventUtil.getEvent(e);
	var x1 = EventUtil.getEventX(e);
	var y1 = EventUtil.getEventY(e);
	tempdiv.style.left = (parseInt(tempdiv.style.left) + (x1-Qwindows.x1)) + "px";
	var p = Qwindows.movediv;
	if(tempdiv.style.zIndex < p.style.zIndex)
	tempdiv.style.zIndex = p.style.zIndex + 1;
	if(parseInt(tempdiv.style.left) < 0)
	{
		tempdiv.style.left = "0px";
	}
	if(parseInt(tempdiv.style.left) > Qwindows.MoveWidth)
	{
		tempdiv.style.left = Qwindows.MoveWidth + "px";
	}
	tempdiv.style.top  = (parseInt(tempdiv.style.top) + (y1-Qwindows.y1)) + "px";
	if(parseInt(tempdiv.style.top) < 0)
	{
		tempdiv.style.top = "0px";
	}
	if(parseInt(tempdiv.style.top) > Qwindows.MoveHeight)
	{
		tempdiv.style.top = Qwindows.MoveHeight + "px";
	}
	Qwindows.x1 = x1;
	Qwindows.y1 = y1;
	e.returnValue = false;
	return false;
}
function winMouseup(e)
{
	var Event = arguments[0];
	var obj = Event.target || Event.srcElement;
	var p = Qwindows.movediv;
	EventUtil.removeEventHandler(document,'mousemove',winMousemove);
	if($("tempdiv"))
	{
		$("tempdiv").parentNode.removeChild($("tempdiv"));
	}
	var e = EventUtil.getEvent(e);
	var x = EventUtil.getEventX(e);
	var y = EventUtil.getEventY(e);
	p.style.left = (parseInt(p.style.left) + (x-Qwindows.x)) + "px";
	if(parseInt(p.style.left) < 0)
	{
		p.style.left = "0px";
	}
	if(parseInt(p.style.left) > Qwindows.MoveWidth)
	{
		p.style.left = Qwindows.MoveWidth + "px";
	}
	p.style.top  = (parseInt(p.style.top) + (y-Qwindows.y)) + "px";
	if(parseInt(p.style.top) < 0)
	{
		p.style.top = "0px";
	}
	if(parseInt(p.style.top) > Qwindows.MoveHeight)
	{
		p.style.top = Qwindows.MoveHeight + "px";
	}
	if(coos.browser.msie)
	{
		Qwindows.movediv.releaseCapture ();
	}
	else
	{
		window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
	}
	Qwindows.moveid = "";
	Qwindows.x = 0;
	Qwindows.y = 0;
	Qwindows.movediv = null;
	EventUtil.removeEventHandler(document,'mouseup',winMouseup);
	e.returnValue = false;
	return false;
}
Qwindows.dragForIE = function(div)
{
	var p = $(div.id.substring(0, div.id.length-6));
	div.onmousedown = function(e)
	{
		var e = EventUtil.getEvent(e);
		Qwindows.x = EventUtil.getEventX(e);
		Qwindows.y = EventUtil.getEventY(e);
		Qwindows.x1 = Qwindows.x;
		Qwindows.y1 = Qwindows.y;
		Qwindows.moveid = div.id;
		if(!p.style.width||!p.style.height)
		{
			p.style.width = parseInt(Qwindows.winW) + "px";
			p.style.height = parseInt(Qwindows.winH) + "px";
		}
		if(!p.style.left||!p.style.top)
		{
			p.style.left = (Qwindows.x - parseInt(p.style.width)/2) + "px";
			p.style.top  = Math.abs(Qwindows.y-10) + "px";
		}
		Qwindows.MoveWidth  = parseInt(Qwindows.mainW) - parseInt(p.style.width);
		Qwindows.MoveHeight = parseInt(Qwindows.mainH) - parseInt(p.style.height);
		if(Qwindows.MoveWidth < 0)
		{
			Qwindows.MoveWidth = 0;
		}
		if(Qwindows.MoveHeight < 0)
		{
			Qwindows.MoveHeight = 0;
		}
		if(Qwindows.getWindow(p.id))
		{
		   var win = Qwindows.getWindow(p.id);
		   win.toTop();
		}
		tempdiv = document.createElement ("div");
		tempdiv.id = "tempdiv";
		var deskStyle = "margin:0px;padding:0px;position:absolute;left:" + p.style.left + ";top:" + p.style.top + ";width:" + p.style.width + ";height:" + p.style.height + ";z-index:" + (p.style.zIndex +1) + ";border:2px solid #9abbe8;";
		tempdiv.style.cssText = deskStyle;
		document.body.appendChild(tempdiv);
		if(coos.browser.msie)
		{
			div.setCapture ();
		}
		else
		{
   			window.captureEvents(Event.MOUSEMOVE | Event.MOUSEUP);
		}
	};
	div.onmousemove = function(e)
	{
		if(Qwindows.moveid == this.id && $("tempdiv"))
		{
			var tempdiv = $("tempdiv");
			var e = EventUtil.getEvent(e);
			var x1 = EventUtil.getEventX(e);
			var y1 = EventUtil.getEventY(e);
			tempdiv.style.left = (parseInt(tempdiv.style.left) + (x1-Qwindows.x1)) + "px";
			if(parseInt(tempdiv.style.left) < 0)
			{
				tempdiv.style.left = "0px";
			}
			if(parseInt(tempdiv.style.left) > Qwindows.MoveWidth)
			{
				tempdiv.style.left = Qwindows.MoveWidth + "px";
			}
			tempdiv.style.top  = (parseInt(tempdiv.style.top) + (y1-Qwindows.y1)) + "px";
			if(parseInt(tempdiv.style.top) < 0)
			{
				tempdiv.style.top = "0px";
			}
			if(parseInt(tempdiv.style.top) > Qwindows.MoveHeight)
			{
				tempdiv.style.top = Qwindows.MoveHeight + "px";
			}
			Qwindows.x1 = x1;
			Qwindows.y1 = y1;
		}
	};
	div.onmouseup = function(e)
	{
		if($("tempdiv"))
		{
			$("tempdiv").parentNode.removeChild($("tempdiv"));
		}
		if(Qwindows.moveid == this.id)
		{
			var e = EventUtil.getEvent(e);
			var x = EventUtil.getEventX(e);
			var y = EventUtil.getEventY(e);
			if((x-Qwindows.x)!=0&&(y-Qwindows.y)!=0)
			{
				p.style.left = (parseInt(p.style.left) + (x-Qwindows.x)) + "px";
				if(parseInt(p.style.left) < 0)
				{
					p.style.left = "0px";
				}
				if(parseInt(p.style.left) > Qwindows.MoveWidth)
				{
					p.style.left = Qwindows.MoveWidth + "px";
				}
				p.style.top  = (parseInt(p.style.top) + (y-Qwindows.y)) + "px";
				if(parseInt(p.style.top) < 0)
				{
					p.style.top = "0px";
				}
				if(parseInt(p.style.top) > Qwindows.MoveHeight)
				{
					p.style.top = Qwindows.MoveHeight + "px";
				}
			}
			if(coos.browser.msie)
			{
				div.releaseCapture ();
			}
			else
			{
    			window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
			}
			Qwindows.moveid = "";
			Qwindows.x = 0;
			Qwindows.y = 0;
			document.body.focus();
			return false;
		}
	};
}
Qwindows.getwinWidth = function()
{
	if (window.innerWidth)
	{
		Qwindows.winWidth = window.innerWidth;
	}
	else if((document.body) && (document.body.clientWidth))
	{
		Qwindows.winWidth = document.body.clientWidth;
	}
	if (document.documentElement && document.documentElement.clientWidth)
	{
		Qwindows.winWidth = document.documentElement.clientWidth;
	}
	return Qwindows.winWidth;
}
Qwindows.getwinHeight = function()
{
	if (window.innerHeight)
	{
		Qwindows.winHeight = window.innerHeight;
	}
	else if((document.body) && (document.body.clientHeight))
	{
		Qwindows.winHeight = document.body.clientHeight;
	}
	if (document.documentElement  && document.documentElement.clientHeight)
	{
		Qwindows.winHeight = document.documentElement.clientHeight;
	}
	return Qwindows.winHeight;
}
function fSetBorderMouseOver(obj) {
	obj.style.borderRight="1px solid #185dce";
	obj.style.borderBottom="1px solid #428ade";
	obj.style.borderTop="1px solid #185dce";
	obj.style.borderLeft="1px solid #428ade";
}
function fSetBorderMouseOut(obj) {
	obj.style.border="none";
}
function fSetBorderMouseDown(obj) {
	obj.style.borderRight="1px #4081d5 solid";
	obj.style.borderBottom="1px #4081d5 solid";
	obj.style.borderTop="1px #185dce solid";
	obj.style.borderLeft="1px #185dce solid";
}
function fSetAlphaMouseOver(obj) {
	obj.style.filter  = "Alpha(Opacity=60)";
	obj.style.opacity = ".6";
}
function fSetAlphaMouseOut(obj) {
	obj.style.filter  = "";
	obj.style.opacity = "";
}
Qwindows.onresize = function()
{
	bodyStyle = "margin:0px;padding:0px;left:0px;top:0px;width:100%;height:100%;overflow-x:hidden;overflow-y:hidden;background-color:" + Qwindows.BackColor + ";background-image:url(" + Qwindows.path + Qwindows.BackImage + ");background-position: left top;background-repeat:repeat-x;";
	document.body.style.cssText = bodyStyle;
	Qwindows.barH		= 28;
	Qwindows.startbarW	= 135;
	Qwindows.sysbarW	= 80;
	Qwindows.mainW  = Qwindows.getwinWidth();
	Qwindows.mainH	= Qwindows.getwinHeight()-Qwindows.barH;
	Qwindows.workbarW = Qwindows.mainW - Qwindows.startbarW - Qwindows.sysbarW;
	if($("mainDiv"))
	{
		$("mainDiv").style.width     = Qwindows.mainW + "px";
		$("mainDiv").style.height    = Qwindows.mainH + "px";
		$("startbarDiv").style.top   = Qwindows.mainH + "px";
		$("workbarDiv").style.top    = Qwindows.mainH + "px";
		$("sysbarDiv").style.top     = Qwindows.mainH + "px";
		Qwindows.workbarW = Qwindows.mainW - Qwindows.startbarW - Qwindows.sysbarW;
		$("workbarDiv").style.width  = Qwindows.workbarW + "px";
		$("sysbarDiv").style.left    = (Qwindows.startbarW + Qwindows.workbarW) + "px";
		if($("mainDiv_bgdiv"))
		{
			var div = $("mainDiv_bgdiv");
			var img = $("mainDiv_bgimg")
			div.style.width = Qwindows.mainW + "px";
			div.style.height = Qwindows.mainH + "px";
			if(parseInt(img.width)*parseInt(div.style.height) >= parseInt(div.style.width)*parseInt(img.height))
			{
				img.style.height = (parseInt(div.style.width)/parseInt(img.width))*parseInt(img.height);
				img.style.width = div.style.width;
			}
			else
			{
				img.style.width = (parseInt(div.style.height)/parseInt(img.height))*parseInt(img.width);
				img.style.height = div.style.height;
			}
		}
		var divs = $("mainDiv").getElementsByTagName("div");
		var len    = divs.length;
		for(var i = 0; i < len; i++)
		{
			if(divs[i].id.substr(0,4) == "win_" && divs[i].parentNode.id == "mainDiv")
			{
				var w = parseInt(divs[i].style.left) + parseInt(divs[i].style.width);
				var h = parseInt(divs[i].style.top) + parseInt(divs[i].style.height);
				if(w > Qwindows.mainW)
				{
					divs[i].style.left = (Qwindows.mainW - parseInt(divs[i].style.width) -10) + "px";
					if(parseInt(divs[i].style.left) < 0)
					{
						divs[i].style.left = "0px";
					}
				}
			}
		}
	}
}
window.onload = function ()
{
	Qwindows.onresize();
	window.onresize = Qwindows.onresize;
}
window.onblur =function()
{
	if($("tempdiv"))
	{
		$("tempdiv").parentNode.removeChild($("tempdiv"));
	}
}
function getJsPath()
{
	var scripts = document.getElementsByTagName("script");
	for (var i = 0; i < scripts.length; i++)
	{
		if(scripts[i].src.indexOf("js/Qwindows.js") != -1)
		{
			var path = scripts[i].src.split("js/Qwindows.js")[0];
			if(path && Qwindows.path == "images/Qwindows/")
			{
				Qwindows.setPath(path + "images/Qwindows/");
			}
		}
	}
}
try
{
	getJsPath();
}
catch(e)
{
	setTimeout ("getJsPath()",100);
}
